package com.e3.basdoc.cust.model;

import java.util.Date;
import java.util.List;

import com.e3.basdoc.region.model.RegionModel;
import com.e3.template.model.TGFTreeModel;

public class CustModel extends TGFTreeModel implements CustFields {

	private static final long serialVersionUID = -3357490907479233129L;

	private RegionModel region;

	private Long regionId;

	private Long currencyId;
	
	private List<CustAccountModel> custAccounts;

	// 基本信息
	public String getCode() {
		return get(CustFields.CODE);
	}

	public void setCode(String code) {
		set(CustFields.CODE, code);
	}

	public String getName() {
		return get(CustFields.NAME);
	}

	public void setName(String name) {
		set(CustFields.NAME, name);
	}

	public String getShortName() {
		return get(CustFields.SHORT_NAME);
	}

	public void setShortName(String shortName) {
		set(CustFields.SHORT_NAME, shortName);
	}

	public String getType() {
		return get(CustFields.TYPE);
	}

	public void setType(String type) {
		set(CustFields.TYPE, type);
	}

	public CustModel getParentCust() {
		return get(CustFields.PARENT_CUST);
	}

	public void setParentCust(CustModel parentCust) {
		set(CustFields.PARENT_CUST, parentCust);
		if(parentCust!=null){
			setParentId(parentCust.getId());
		}
		else{
			setParentId(0L);
		}
	}

	public Long getRegionId() {
		if(this.regionId==null){
			return getRefModelId(CustModel.REGION);
		}
		return regionId;
	}

	public void setRegionId(Long regionId) {
		this.regionId = regionId;
	}

	public RegionModel getRegion() {
		return get(CustFields.REGION);
	}

	public void setRegion(RegionModel region) {
		set(CustFields.REGION, region);
		if(region!=null){
			setRegionId(region.getId());
		}
		else{
			setRegionId(0L);
		}
	}

	public String getBusinessAddress() {
		return get(CustFields.BUSINESS_ADDRESS);
	}

	public void setBusinessAddress(String businessAddr) {
		set(CustFields.BUSINESS_ADDRESS, businessAddr);
	}

	public String getContactAddress() {
		return get(CustFields.CONTACT_ADDRESS);
	}

	public void setContactAddress(String contactAddr) {
		set(CustFields.CONTACT_ADDRESS, contactAddr);
	}

	public String getFax() {
		return get(CustFields.FAX);
	}

	public void setFax(String fax) {
		set(CustFields.FAX, fax);
	}

	public String getZipcode() {
		return get(CustFields.ZIPCODE);
	}

	public void setZipcode(String zipcode) {
		set(CustFields.ZIPCODE, zipcode);
	}

	public String getTelphone() {
		return get(CustFields.TELPHONE);
	}

	public void setTelphone(String telphone) {
		set(CustFields.TELPHONE, telphone);
	}

	public String getEmail() {
		return get(CustFields.EMAIL);
	}

	public void setEmail(String email) {
		set(CustFields.EMAIL, email);
	}

	public String getRemark() {
		return get(CustFields.REMARK);
	}

	public void setRemark(String remark) {
		set(CustFields.REMARK, remark);
	}

	// 注册信息
	public String getRegisterAddress() {
		return get(CustFields.REGISTER_ADDRESS);
	}

	public void setRegisterAddress(String registerAddress) {
		set(CustFields.REGISTER_ADDRESS, registerAddress);
	}

	public String getLegalPerson() {
		return get(CustFields.LEGAL_PERSON);
	}

	public void setLegalPerson(String legalPerson) {
		set(CustFields.LEGAL_PERSON, legalPerson);
	}

	public String getLegalPersonIdcard() {
		return get(CustFields.LEGAL_PERSON_IDCARD);
	}

	public void setLegalPersonIdcard(String legalPersonIdcard) {
		set(CustFields.LEGAL_PERSON_IDCARD, legalPersonIdcard);
	}

	public String getRegisterNo() {
		return get(CustFields.REGISTER_NO);
	}

	public void setRegisterNo(String registerNo) {
		set(CustFields.REGISTER_NO, registerNo);
	}

	public String getTaxNo() {
		return get(CustFields.TAX_NO);
	}

	public void setTaxNo(String taxNo) {
		set(CustFields.TAX_NO, taxNo);
	}

	public String getContactPerson() {
		return get(CustFields.CONTACT_PERSON);
	}

	public void setContactPerson(String contactPerson) {
		set(CustFields.CONTACT_PERSON, contactPerson);
	}

	public String getContactWay() {
		return get(CustFields.CONTACT_WAY);
	}

	public void setContactWay(String contactWay) {
		set(CustFields.CONTACT_WAY, contactWay);
	}

	public Date getFoundTime() {
		return get(CustFields.FOUND_TIME);
	}

	public void setFoundTime(Date foundTime) {
		set(CustFields.FOUND_TIME, foundTime);
	}

	public Date getRegisterStartTime() {
		return get(CustFields.REGISTER_START_TIME);
	}

	public void setRegisterStartTime(Date registerStartTime) {
		set(CustFields.REGISTER_START_TIME, registerStartTime);
	}

	public Date getRegisterEndTime() {
		return get(CustFields.REGISTER_END_TIME);
	}

	public void setRegisterEndTime(Date registerEndTime) {
		set(CustFields.REGISTER_END_TIME, registerEndTime);
	}

	public Long getCurrencyId() {
		if(currencyId==null){
			return getRefModelId(CustModel.CURRENCY);
		}
		return currencyId;
	}

	public void setCurrencyId(Long currencyId) {
		this.currencyId = currencyId;
	}

	public String getTaxpayerType() {
		return get(CustFields.TAXPAYER_TYPE);
	}

	public void setTaxpayerType(String taxpayerType) {
		set(CustFields.TAXPAYER_TYPE, taxpayerType);
	}

	public List<CustAccountModel> getCustAccountList() {
		return get(CustFields.BANK_ACCOUNTS);
	}

	public void setCustAccountList(List<CustAccountModel> list) {
		set(CustFields.BANK_ACCOUNTS, list);
	}

	public String toString() {
		return getName();
	}

	public String[] getModelFields() {
		return fieldNames;
	}

	@Override
	public String getParentFiledName() {
		return PARENT_CUST;
	}

}
